﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using VirtualPress.Infrastructure.Entities.Entity;
using VirtualPress.Portal.Biz;
using VirtualPress.Tool.Framework;

namespace VirtualPress.Portal.Web.Controllers
{
    [Authorize]
    public class ZoneController : Controller
    {
        //
        // GET: /Zone/

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult Newjournals()
        {
            return View();
        }

        public ActionResult Journals()
        {
            return View();
        }

        #region 稿件
        public ActionResult Article()
        {
            return View();
        }
        #endregion

        public ActionResult Auditing()
        {
            return View();
        }

        #region ajax
        public string getdiary(int id)
        {
            Diary diary = KitBiz.GetOne(id);
            if (diary != null && diary.UserName == HttpContext.User.Identity.Name)
            {
                return diary.Content;
            }
            return "";
        }

        [ValidateInput(false)]
        public string writediary(string content)
        {
            content = Server.HtmlEncode(content);
            var item = KitBiz.NewDiary(new Diary()
            {
                Content = content,
                RecordDate = DateTime.Now,
                UserName = HttpContext.User.Identity.Name
            });
            if (item != null)
            {
                return "suc";
            }
            return "fal";
        }
        #endregion
    }
}
